﻿@using System.Globalization
@model PagedList.IPagedList<Doan.Website.Models.Ask>
           
@foreach (var item in Model)
{
        <div class="bv-Group left clearfix"> 
            <div class="left w160">
                <div style="text-align: center;" >
                    <a href=@Url.Action("Question", "Home", new { id = item.AskId })>
                        <img src="../../Content/Image/icon-question.png" height="100" width="100" alt="Ảnh Minh Họa" />
                    </a>
                </div>
            </div>
            <div class="right w450">
                <div style="margin-bottom: 10px;">
                    <a href=@Url.Action("Question", "Home", new { id = item.AskId })>@item.Title</a>
                </div>
                <div>@Html.Raw(@item.Content)</div>                        
            </div> 
        </div>
}
<script>
    $(document).ready(function () {
        var page = @ViewBag.pageNumber;
            var id = "cmpage" + page;
            $(".pagingbar a").removeClass("active");
            $('#' + id).addClass('cmpageActive');
        });
    </script>
    
    @if (Model.PageCount > 1)
    {
        <div class="pagingbar">
            @Ajax.ActionLink("Đầu", "ListQuestionPartial", new {page = 1}, new AjaxOptions {UpdateTargetId = "listquestion"})
            @Ajax.ActionLink("<", "ListQuestionPartial", new {page = Model.PageNumber - 1}, new AjaxOptions {UpdateTargetId = "listquestion"})
            @for (int i = 1; i <= Model.PageCount; i++)
            {
                var page = i.ToString(CultureInfo.InvariantCulture);
                @Ajax.ActionLink(page, "ListQuestionPartial", new {page = i}, new AjaxOptions {UpdateTargetId = "listquestion"}, new {@id = "cmpage" + page})
            }
            @Ajax.ActionLink(">", "ListQuestionPartial", new {page = Model.PageNumber + 1}, new AjaxOptions {UpdateTargetId = "listquestion"})
            @Ajax.ActionLink("Cuối", "ListQuestionPartial", new {page = Model.PageCount}, new AjaxOptions {UpdateTargetId = "listquestion"})
        </div>
    }
